package com.lm.jackson.controller;


import com.lm.jackson.model.User;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/api/users")
public class UserController {

    @GetMapping("/{id}")
    public User getUser(@PathVariable Long id) {
        User u = new User();
        u.setId(id);
        u.setName("Alice");
        u.setPassword("secret123");
        u.setCreateTime(LocalDateTime.now());
        u.setEmail(null);
        return u;
    }

    @PostMapping
    public String createUser(@RequestBody User user) {
        return "用户 " + user.getName() + " 创建成功";
    }
}
